<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'jizhang.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script type='text/javascript' src='resource/js/jquery-1.9.1.min.js'></script>
</head>
  
<body>
	<a href="UserAction?op=QU"><input type="button" value="退出"></a>
	<table border="1" cellspacing="0" cellpadding="0">
		<tr>
			<th>当前账户名：</th><td>${acc.ac_name }</td>
			<th>可用余额：</th>
			<td>
				${acc.availableBalance }
				<input type="button" value="查看账单" onclick="showBill(0);" style="cursor: pointer;">
			</td>
		</tr><tr>
			<th colspan="3" align="left">金融账户</th>
			<th align="right">
				<input type="button" value="新建金融账户" onclick="addCashCard();" style="cursor: pointer;">
				<input type="button" value="记账" onclick="chargeAccount();" style="cursor: pointer;">
			</th>
		</tr><tr>	
			<th>名称</th>
			<th>余额</th>
			<th>更新日期</th>
			<th>操作</th>
		</tr>
		<c:forEach items="${carries }" var="obj">
	  	<tr>
	  		<td align="center">${obj.ca_name }</td>
	  		<td align="center">${obj.availableBalance }</td>
	  		<td align="center"><fmt:formatDate value="${obj.updateTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
	  		<td align="center">
	  			<input type="button" value="查看账单" onclick="showBill(${obj.id });" style="cursor: pointer;">
	  		</td>
	  	</tr>
	  	</c:forEach>
	</table>
	
	<form action="<%=basePath %>TradeLogAction" id="theForm" method="post">
		<input type="hidden" name="op" id="op">
		<input type="hidden" name="carr" id="carr">
		<input type="hidden" name="id" id="id" value="${acc.id }">
		<input type="hidden" name="acc" id="acc" value="${acc.id }">
	</form>
</body>
<script type="text/javascript">
function chargeAccount(){
	$("#op").val("SH");
	$("#theForm").submit();
}
function showBill(carr){
	$("#op").val("LI");
	if(carr > 0){
		$("#carr").val(carr);
	}else{
		$("#carr").val('');
	}
	$("#theForm").submit();
}
function addCashCard(){
	$("#op").val("AD");
	var path = '<%=basePath%>CarrierAction';
	$('#theForm').attr("action", path).submit();
}
</script>
</html>
